#include "platform.h"


#if defined(_MSC_VER) && _MSC_VER < 1400
#include <string.h> // memchr()
/// Find the length of STRING, but scan at most MAXLEN characters.
/// If no '\0' terminator is found in that many characters, return MAXLEN.
size_t strnlen(const char* string, size_t maxlen)
{
	const char* end = memchr(string, '\0', maxlen);
	return end ? (size_t) (end - string) : maxlen;
}
#endif


#if defined(_MSC_VER)
#include <fcntl.h> // _chsize()
int ftruncate(int fd, unsigned int length)
{
    return _chsize(fd, length);
}
#endif
